<?php

namespace app\common\model;

use app\common\model\BaseModel as BaseModel;

/**
 * Class Robot
 * @package app\model
 * @property int $id
 * @property string $nickname
 * @property string $headImgUrl
 * @property int $updated
 * @property int $created
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037579
 * @link https://www.kancloud.cn/manual/think-orm/1257998
 * @link https://www.kancloud.cn/thinkphp/master-database-and-model/265551
 */
class Platform extends BaseModel
{
    protected $name = 'Platform';

    // 头像
    public function getHeadImgAttr($value, $data)
    {
        if (is_blank($data['headImgUrl'] ?? null)) {
            $data['headImgUrl'] = '/storage/static/images/member/touxiang.png';
        }
        return image_url($data['headImgUrl']);
    }

    // 用户头像
    public function getHeadImgThumbAttr($value, $data)
    {
        if (is_blank($data['headImgUrl'] ?? null)) {
            $data['headImgUrl'] = '/storage/static/images/member/touxiang.png';
        }
        return image_url($data['headImgUrl'], 'thumb');
    }

    public function getCropImgAttr($value, $data)
    {
        return '';
    }

    /**
     * 1对1
     * @return \think\model\relation\HasOne
     */
    //    public function one(){
    //        return $this->hasOne( Test1::class, 'Test1表中的键', 'Robot表中的键');
    //    }

    /**
     * 1对多
     * @return \think\model\relation\HasMany
     */
    //    public function many(){
    //        return $this->hasMany( Test1::class, 'Test1表中的键', 'Robot表中的键');
    //    }

    /**
     * 多对多
     * @return \think\model\relation\BelongsToMany
     */
    //    public function belongs(){
    //        return $this->belongsToMany( Test1::class, '中间表', '中间表中Test1的键', '中间表中Robot的键');
    //    }
}
